package com.code.test.first.backtracking;

/**
 * 回文串判断
 */
public class isPalindrome {

    public static void main(String[] args) {
        Boolean ispa = isPalid2("2332");
        System.out.println(ispa);
    }

    public static boolean isPalid(String input) {
        int start = 0;
        int end = input.length() - 1;
        while (start < end) {
            if (input.charAt(start) != input.charAt(end)) {
                return false;
            }
            start++;
            end--;
        }
        return true;
    }

    public static boolean isPalid2(String input) {
        int start = 0;
        int end = input.length() - 1;
        for (int i = start, j = end; i < j; i++, j--) {
            if (input.charAt(i) != input.charAt(j)) {
                return false;
            }
        }
        return true;
    }

}
